package com.gduf.lsm.mapper;

import com.gduf.lsm.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author lsm
 * @Data
 */
@Mapper
public interface UserMapper {
    //由用户名查询整条数据
    @Select("select * from user where username=#{username}")
    User selectByUsername(String username);

    //添加金额
    @Update("update user set money=#{m} where id=#{user};")
    void updateMoney(Integer user, float m);

    //添加志愿时长
    @Update("update user set volu_time=#{v} where id=#{userId}")
    void updateVoluTime(Integer userId, float v);

    void insert(User user);

    void deleteById(Integer id);

    void updateById(User user);

    @Select("select * from user where id=#{id}")
    User selectById(Integer id);

    List<User> selectAll(User user);


    /**
     * 统计所有用户数
     * @return
     */
    @Select("select count(id) from user")
    int countAll();
}
